#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int x = 0, y = 0;
	scanf("%d%d", &x, &y);
	int c = 0;
	c = x % y;
	if (c == 0)
		printf("%d", x);
	else
		while (c != 0)
		{
			x = y;
			y = c;
			c = x % y;
		}
	printf("%d", y);
	return 0;
}